package entity

import (
	"shqsoft.cn/pasnj/base"

	"github.com/jinzhu/gorm"
)

//GJZSDR 国际中收导入
type GJZSDR struct {
	ID   int     `gorm:"AUTO_INCREMENT;primary_key;column:ID"`
	KHYF int     `gorm:"column:KHYF"`
	KHJL string  `gorm:"column:KHJL;size:100"`
	BZSX float64 `gorm:"column:BZSX"`
	ZYSX float64 `gorm:"column:ZYSX"`
}

//GjzsAfterImport 导入后执行
func GjzsAfterImport(tx *gorm.DB, params map[string]string) (err error) {
	err = tx.Exec("UPDATE T_BASE_YXFY_GJZS SET EMID=B.ID "+
		"FROM T_BASE_YXFY_GJZS A INNER JOIN T_SysUser B ON (A.KHJL=B.SysUserName) OR (A.KHJL=B.SysUserID)"+
		"WHERE KHYF=?", params["KHYF"]).Error
	if err != nil {
		return err
	}
	return nil
}

//TableName 国际中收导入表
func (GJZSDR) TableName() string {
	return "T_BASE_YXFY_GJZS"
}

//GJZSDREF 返回结构体
func GJZSDREF() base.EntityFunc {
	return func() interface{} {
		entity := GJZSDR{}
		return &entity
	}
}

//GJZSDRESF 返回结构体数组
func GJZSDRESF() base.EntitiesFunc {
	return func() interface{} {
		var entities []GJZSDR
		return &entities
	}
}

func init() {
	base.DaoPoolObj.Put("GJZSDR", base.NewDefaultDao(GJZSDREF(), GJZSDRESF(), nil))
	base.SetAfterCallBack("GJZSDR", GjzsAfterImport)

}
